const tableConfig = {
	stripe: true,
	border: true,
	maxHeight: '80vh',
	columns: [
		{
			label: '批次编号',
			prop: 'batch',
		},
		{
			label: '数据编辑截止日期',
			prop: 'editValidityDate',
		},
		{
			label: '数据归档日期',
			prop: 'archivingDate',
			render: ({ row }) => {
				return '每月' + row.archivingDate + '号'
			},
		},
		{
			label: '数据申诉期',
			prop: 'appealDate',
			render: ({ row }) => {
				return row.appealDate + '天'
			},
		},
		{
			label: '数据固化期',
			prop: 'solidificationDate',
			render: ({ row }) => {
				return '每月' + row.solidificationDate + '号'
			},
		},
		{
			label: '是否有效',
			prop: 'isEffective',
			span: 8,
		},
		{
			label: '创建时间',
			prop: 'createTime',
		},
		{
			label: '操作',
			prop: 'menu',
			width: 300,
			fixed: 'right',
		},
	],
}
//  规则
const numberRules1 = (rule, value, callback) => {
	let val = Number(value)
	console.log(val, typeof val == 'number')
	if (isNaN(val)) {
		callback(Error('请输入数值'))
	} else if (val <= 0) {
		callback(Error('请输入大于0的值'))
	} else {
		callback()
	}
}
const numberRules2 = (rule, value, callback) => {
	let val = Number(value)
	console.log(val, typeof val == 'number')
	if (isNaN(val)) {
		callback(Error('请输入数值'))
	} else if (val <= 0 || val > 31) {
		callback(Error('请输入1-31之间的数值'))
	} else {
		callback()
	}
}
export const formConfig = {
	label: '数据管理设置',
	prop: 'base0',
	inline: false,
	showBtn: true,
	labelPosition: 'left',
	column: [
		{
			label: '批次编号',
			prop: 'batch',
			type: 'input',
			span: 24,
		},
		{
			label: '数据编辑截止日期',
			prop: 'editValidityDate',
			type: 'datetime',
			valueFormat: 'YYYY-MM-DD HH:mm:ss',
			span: 12,
		},
		{
			label: '数据归档日期',
			prop: 'archivingDate',
			type: 'input',
			prepend: '每月',
			append: '号',
			span: 12,
			placeholder: '请输入期限（1-28号）',
			rules: [{ validator: numberRules2, trigger: 'change' }],
		},
		{
			label: '数据申诉期',
			prop: 'appealDate',
			type: 'input',
			append: '天',
			span: 12,
			rules: [{ validator: numberRules1, trigger: 'change' }],
		},
		{
			label: '数据固化期',
			prop: 'solidificationDate',
			type: 'input',
			prepend: '每月',
			append: '号',
			span: 12,
			rules: [{ validator: numberRules2, trigger: 'change' }],
		},
	],
}
const searchConfig = {
	inline: true,
	showBtn: true,
	labelPosition: 'left',
	column: [
		{
			label: '批次号',
			type: 'input',
			prop: 'batch',
			placeholder: '请输入批次号',
			span: 12,
		},
		{
			label: '是否有效',
			type: 'select',
			prop: 'isEffective',
			filterKey: 'value',
			multiple: false,
			placeholder: '请输入批次号',
			dicData: [
				{
					label: '有效',
					value: 1,
				},
				{
					label: '无效',
					value: 0,
				},
			],
			span: 12,
		},
	],
}
export const baseConfig: any = {
	pageName: '数据管理设置',
	addLabel: '添加',
	dictcodes: [],
	rowKey: 'id',
	tipLabel: 'batch',
	api: {
		index: 'dataManagementSettings_page',
		add: 'dataManagementSettings_add',
		edit: 'dataManagementSettings_edit',
		delete: 'dataManagementSettings_del',
	},
	auth: {
		index: 'view_dataManagementSettings_page',
		add: 'view_dataManagementSettings_add',
		edit: 'view_dataManagementSettings_edit',
		delete: 'view_dataManagementSettings_del',
	},
	paramsObj: {
		code: 3007,
	},
	menuBtn: [
		{
			icon: 'editor',
			label: '编辑',
			type: 'primary',
			operate: 'edit',
			auth: 'view_dataManagementSettings_edit',
			text: true,
			show: true,
		},
		{
			icon: 'delete',
			label: '删除',
			type: 'primary',
			operate: 'delete',
			auth: 'view_dataManagementSettings_del',
			text: true,
			show: true,
		},
	],
	dialogConfig: {
		width: '65%',
	},
	searchConfig,
	tableConfig,
	formConfig,
}
